package com.offcn.controller;

import com.offcn.common.JsonController;
import com.offcn.pojo.Department;
import com.offcn.pojo.Member;
import com.offcn.pojo.Role;
import com.offcn.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@RequestMapping("role")
public class RoleController extends JsonController {

    @Autowired
    RoleService roleService;
     /*
       需求：展示权限列表
       URL：http://localhost:8080/eastCMS/role/getAll
       逻辑： 1： 接收请求
              2：查询role （权限）
              3：放到json
     */

     @RequestMapping("getAll")
     public  void  getAll(HttpServletRequest request, HttpServletResponse response){

        Member memberSession = (Member) request.getSession().getAttribute("member");

         List<Role> roleList=roleService.selectRoleByMemberSession(memberSession);

        JsonUtilObjecToJson(response,"200","success",roleList);


    }

}
